package com.yeping.controller;

import com.yeping.domain.ResponseResult;
import com.yeping.domain.entity.User;
import com.yeping.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/userInfoAll")
    public ResponseResult userInfo(Long pageNum,Long pageSize,String userName){
        return userService.userInfoAll(pageNum,pageSize,userName);
    }

    @PostMapping
    public ResponseResult addUser(@RequestBody User user){
        return userService.register(user);
    }

    @DeleteMapping("/{id}")
    public ResponseResult delUser(@PathVariable Long id){
        return userService.delUser(id);
    }

    @PutMapping
    public ResponseResult updateUser(@RequestBody User user){
        return userService.updateUser(user);
    }

    @PostMapping("/del/batch")
    public ResponseResult delBatchUser(@RequestBody List<Long> ids){
        return userService.delBatchUser(ids);
    }
}
